#include<iostream>
#include<signal.h>
#include<unistd.h>
#include<stdlib.h>
using namespace std;

void sigcb(int signo)
{
  cout<<"收到信号" << signo <<"结束"<<endl;
  exit(0);
}

//int main()
//{
//  signal(2,sigcb);
//  while(1)
//  {
//    sleep(1);
//    cout << "等待发送信号中"<<"我的Pid: "<< getpid() << endl; 
//  }
//  return 0;
//}

int main()
{
  signal(2,sigcb);
 struct sigaction mak,omak;
 mak.sa_handler = sigcb;
 sigaction(2,&mak,&omak);
  while(1)
  {
    sleep(1);
    cout << "等待发送信号中"<<"我的Pid: "<< getpid() << endl; 
  }
  return 0;
}
